var a = getApp();

Component({
    properties: {
        params: {
            type: null
        }
    },
    data: {
        active: 1,
        status: "",
        announceList: "",
        broadcastlist: "",
        apiType: "recommend",
        playBackData: "",
        playBackShow: !1,
        allLivelistData: [],
        allLivelistData_activitys1: [],
        allLivelistData_activitys2: [],
        all_colOneHeight: 0,
        all_colTwoHeight: 0,
        isLoadMore_all: !0,
        page_all: 1,
        total_page_all: 0,
        recommendData_activitys1: [],
        recommendData_activitys2: [],
        broadcastlist_activitys1: [],
        broadcastlist_activitys2: [],
        announceList_activitys1: [],
        announceList_activitys2: [],
        playBackData_activitys1: [],
        playBackData_activitys2: [],
        recommendData: [],
        re_colOneHeight: 0,
        re_colTwoHeight: 0,
        br_colOneHeight: 0,
        br_colTwoHeight: 0,
        an_colOneHeight: 0,
        an_colTwoHeight: 0,
        pl_colOneHeight: 0,
        pl_colTwoHeight: 0,
        RecommendBol: !0,
        allLiveBol: !0,
        broadcastlistBol: !0,
        announceListBol: !0,
        playBackDataBol: !0,
        isLoadMore_br: !0,
        page_br: 1,
        total_page_br: 0,
        isLoadMore_an: !0,
        page_an: 1,
        total_page_an: 0,
        isLoadMore_pl: !0,
        page_pl: 1,
        total_page_pl: 0,
        showNumber: 10,
        notload_all: !0,
        notload_br: !0,
        notload_an: !0,
        notload_pl: !0
    },
    lifetimes: {
        attached: function() {},
        moved: function() {},
        detached: function() {}
    },
    attached: function() {},
    ready: function() {},
    pageLifetimes: {
        show: function() {},
        hide: function() {},
        resize: function() {}
    },
    methods: {
        goliveList: function() {
            wx.navigateTo({
                url: "/packageD/directSeeding/liveList/liveList"
            });
        },
        golistPage: function(a) {
            var t = a.currentTarget.dataset.status, e = a.currentTarget.dataset.id, i = a.currentTarget.dataset.backid;
            3 == t ? wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=live"
            }) : 2 == t ? wx.navigateTo({
                url: "/packageD/directSeeding/foreshow/foreshow?id=" + e
            }) : 4 == t && wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=video&backid=" + i
            });
        },
        getMorePdData_all: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.get-all-live-list");
            t.setData({
                isLoadMore_all: !1
            }), this.data.page_all >= this.data.total_page_all || (this.data.page_all = this.data.page_all + 1, 
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    page: this.data.page_all,
                    page_size: this.data.showNumber
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.setData({
                        isLoadMore_all: !0,
                        allLivelistData: t.data.allLivelistData.concat(e.data.data)
                    }), t.data.total_page_all == t.data.page_all && t.setData({
                        notload_all: !1
                    })) : t.setData({
                        page_all: t.data.page_all - 1,
                        isLoadMore_all: !1
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            }));
        },
        getMorePdData_br: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.get-live-list");
            t.setData({
                isLoadMore_br: !1
            }), this.data.page_br >= this.data.total_page_br || (this.data.page_br = this.data.page_br + 1, 
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    status: 3,
                    page: this.data.page_br,
                    page_size: this.data.showNumber
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.setData({
                        isLoadMore_br: !0,
                        broadcastlist: t.data.broadcastlist.concat(e.data.data)
                    }), t.data.total_page_br == t.data.page_br && t.setData({
                        notload_br: !1
                    })) : t.setData({
                        page_br: t.data.page_br - 1,
                        isLoadMore_br: !1
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            }));
        },
        getMorePdData_an: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.get-live-list");
            t.setData({
                isLoadMore_an: !1
            }), this.data.page_an >= this.data.total_page_an || (this.data.page_an = this.data.page_an + 1, 
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    status: 2,
                    page: this.data.page_an,
                    page_size: this.data.showNumber
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.setData({
                        isLoadMore_an: !0,
                        announceList: t.data.announceList.concat(e.data.data)
                    }), t.data.total_page_an == t.data.page_an && t.setData({
                        notload_an: !1
                    })) : t.setData({
                        page_an: t.data.page_an - 1,
                        isLoadMore_an: !1
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            }));
        },
        getMorePdData_pl: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.play-back");
            t.setData({
                isLoadMore_pl: !1
            }), this.data.page_pl >= this.data.total_page_pl || (this.data.page_pl = this.data.page_pl + 1, 
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    page: this.data.page_pl,
                    page_size: this.data.showNumber
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.setData({
                        isLoadMore_pl: !0,
                        playBackData: t.data.playBackData.concat(e.data.data)
                    }), t.data.total_page_pl == t.data.page_pl && t.setData({
                        notload_pl: !1
                    })) : t.setData({
                        page_pl: t.data.page_pl - 1,
                        isLoadMore_pl: !1
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            }));
        },
        onImageError: function(a) {
            var t = a.target.dataset.index, e = a.target.dataset.seltype;
            console.log("图片加载发生错误"), this.onImageLoad({
                target: {
                    dataset: {
                        index: t,
                        seltype: e
                    }
                },
                detail: {
                    width: 2340,
                    height: 1080
                }
            });
        },
        onImageLoad: function(a) {
            var t = a.target.dataset.index, e = a.target.dataset.seltype, i = null, s = a.detail.width / a.detail.height;
            if ("recommend" == e) {
                i = this.data.recommendData[t];
                var l = this.data.recommendData_activitys1, o = this.data.recommendData_activitys2;
                this.data.re_colOneHeight <= this.data.re_colTwoHeight ? (this.data.re_colOneHeight += 176 / s + 60, 
                l.push(i)) : (this.data.re_colTwoHeight += 176 / s + 60, o.push(i)), this.setData({
                    recommendData_activitys1: l,
                    recommendData_activitys2: o
                });
            } else if ("AllLivelist" == e) {
                i = this.data.allLivelistData[t];
                var d = this.data.allLivelistData_activitys1, n = this.data.allLivelistData_activitys2;
                this.data.all_colOneHeight <= this.data.all_colTwoHeight ? (this.data.all_colOneHeight += 176 / s + 60, 
                d.push(i)) : (this.data.all_colTwoHeight += 176 / s + 60, n.push(i)), this.setData({
                    allLivelistData_activitys1: d,
                    allLivelistData_activitys2: n
                });
            } else if ("liveList_1" == e) {
                i = this.data.broadcastlist[t];
                var c = this.data.broadcastlist_activitys1, r = this.data.broadcastlist_activitys2;
                this.data.br_colOneHeight <= this.data.br_colTwoHeight ? (this.data.br_colOneHeight += 176 / s + 60, 
                c.push(i)) : (this.data.br_colTwoHeight += 176 / s + 60, r.push(i)), this.setData({
                    broadcastlist_activitys1: c,
                    broadcastlist_activitys2: r
                });
            } else if ("liveList_2" == e) {
                i = this.data.announceList[t];
                var g = this.data.announceList_activitys1, p = this.data.announceList_activitys2;
                this.data.an_colOneHeight <= this.data.an_colTwoHeight ? (this.data.an_colOneHeight += 176 / s + 60, 
                g.push(i)) : (this.data.an_colTwoHeight += 176 / s + 60, p.push(i)), this.setData({
                    announceList_activitys1: g,
                    announceList_activitys2: p
                });
            } else if ("playBack" == e) {
                i = this.data.playBackData[t];
                var h = this.data.playBackData_activitys1, _ = this.data.playBackData_activitys2;
                this.data.pl_colOneHeight <= this.data.pl_colTwoHeight ? (this.data.pl_colOneHeight += 176 / s + 60, 
                h.push(i)) : (this.data.pl_colTwoHeight += 176 / s + 60, _.push(i)), this.setData({
                    playBackData_activitys1: h,
                    playBackData_activitys2: _
                });
            }
        },
        goforeshow: function(a) {
            var t = a.currentTarget.dataset.id;
            wx.navigateTo({
                url: "/packageD/directSeeding/foreshow/foreshow?id=" + t
            });
        },
        goPlayBackData: function(a) {
            var t = a.currentTarget.dataset.roomid, e = a.currentTarget.dataset.backid;
            wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + t + "&playerType=video&backid=" + e
            });
        },
        golivePage: function(a) {
            var t = a.currentTarget.dataset.id, e = a.currentTarget.dataset.status, i = a.currentTarget.dataset.memberid;
            console.log(a), 1 == e ? wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + t + "&playerType=live"
            }) : wx.navigateTo({
                url: "/packageD/directSeeding/anchorDetail/anchorDetail?id=" + i
            });
        },
        swichTabTItem: function(a) {
            var t = a.detail.index;
            this.setData({
                active: t
            }), 0 == t && this.data.allLiveBol ? (this.data.apiType = "AllLivelist", this.getAllLivelist(), 
            this.data.allLiveBol = !1) : 1 == t && this.data.RecommendBol ? (this.data.apiType = "recommend", 
            this.getRecommend(), this.data.RecommendBol = !1) : 2 == t && this.data.broadcastlistBol ? (this.data.apiType = "liveList", 
            this.data.status = 3, this.getLiveList(3), this.data.broadcastlistBol = !1) : 3 == t && this.data.announceListBol ? (this.data.apiType = "liveList", 
            this.data.status = 2, this.getLiveList(2), this.data.announceListBol = !1) : 4 == t && this.data.playBackDataBol && (this.data.apiType = "playBack", 
            this.getplayBack(), this.data.playBackDataBol = !1);
        },
        getplayBack: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.play-back");
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    page: 1,
                    page_size: this.data.showNumber
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.setData({
                        playBackData: e.data.data,
                        total_page_pl: e.data.last_page
                    }), t.data.total_page_pl == t.data.page_pl && t.setData({
                        notload_pl: !1
                    })) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        },
        getLiveList: function(t) {
            var e = this, i = a.getNetAddresss("plugin.room.frontend.live-list.get-live-list");
            a._postNetWork({
                url: i,
                showToastIn: !1,
                data: {
                    status: t,
                    page: 1,
                    page_size: this.data.showNumber
                },
                success: function(a) {
                    var i = a.data;
                    1 == i.result ? 2 == t ? (e.setData({
                        total_page_an: i.data.last_page,
                        announceList: i.data.data
                    }), e.data.total_page_an == e.data.page_an && e.setData({
                        notload_an: !1
                    })) : 3 == t && (e.setData({
                        total_page_br: i.data.last_page,
                        broadcastlist: i.data.data
                    }), e.data.total_page_br == e.data.page_br && e.setData({
                        notload_br: !1
                    })) : wx.showToast({
                        icon: "none",
                        title: i.msg,
                        duration: 1500
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        },
        getRecommend: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.get-live-recommend");
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    page_size: this.data.showNumber
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? t.setData({
                        recommendData: e.data
                    }) : console.log(e.msg);
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        },
        getAllLivelist: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.get-all-live-list");
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {
                    page_size: this.data.showNumber
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.setData({
                        allLivelistData: e.data.data,
                        total_page_all: e.data.last_page
                    }), t.data.total_page_all == t.data.page_all && t.setData({
                        notload_all: !1
                    })) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        },
        getPlayBackShow: function() {
            var t = this, e = a.getNetAddresss("plugin.room.frontend.live-list.record");
            a._postNetWork({
                url: e,
                showToastIn: !1,
                data: {},
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (t.setData({
                        playBackShow: 1 == e.data.result
                    }), t.data.playBackShow || (t.setData({
                        active: 1
                    }), t.data.apiType = "recommend", t.getRecommend(), t.data.RecommendBol = !1)) : console.log(e.msg);
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        },
        gopage: function(a) {
            var t = a.currentTarget.dataset.status, e = a.currentTarget.dataset.id, i = a.currentTarget.dataset.backid;
            1 == t ? wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=live"
            }) : 2 == t && wx.navigateTo({
                url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=video&backid=" + i
            });
        }
    },
    observers: {
        params: function() {
            this.setData({
                active: 1,
                status: "",
                announceList: "",
                broadcastlist: "",
                apiType: "recommend",
                playBackData: "",
                playBackShow: !1,
                recommendData_activitys1: [],
                recommendData_activitys2: [],
                broadcastlist_activitys1: [],
                broadcastlist_activitys2: [],
                announceList_activitys1: [],
                announceList_activitys2: [],
                playBackData_activitys1: [],
                playBackData_activitys2: [],
                recommendData: [],
                re_colOneHeight: 0,
                re_colTwoHeight: 0,
                br_colOneHeight: 0,
                br_colTwoHeight: 0,
                an_colOneHeight: 0,
                an_colTwoHeight: 0,
                pl_colOneHeight: 0,
                pl_colTwoHeight: 0,
                RecommendBol: !0,
                allLiveBol: !0,
                broadcastlistBol: !0,
                announceListBol: !0,
                playBackDataBol: !0,
                isLoadMore_br: !0,
                page_br: 1,
                total_page_br: 0,
                isLoadMore_an: !0,
                page_an: 1,
                total_page_an: 0,
                isLoadMore_pl: !0,
                page_pl: 1,
                total_page_pl: 0,
                showNumber: 10,
                allLivelistData: [],
                allLivelistData_activitys1: [],
                allLivelistData_activitys2: [],
                all_colOneHeight: 0,
                all_colTwoHeight: 0,
                isLoadMore_all: !0,
                page_all: 1,
                total_page_all: 0,
                notload_all: !0,
                notload_br: !0,
                notload_an: !0,
                notload_pl: !0
            });
            var a = this.data.params.number;
            a && (this.data.showNumber = a), this.data.params.type && 0 == this.data.params.type ? (this.setData({
                active: 0
            }), this.data.apiType = "AllLivelist", this.getAllLivelist(), this.data.allLiveBol = !1) : this.data.params.type && 1 == this.data.params.type ? (this.setData({
                active: 1
            }), this.data.apiType = "recommend", this.getRecommend(), this.data.RecommendBol = !1) : this.data.params.type && 2 == this.data.params.type ? (this.setData({
                active: 2
            }), this.data.apiType = "liveList", this.data.status = 3, this.getLiveList(3), this.data.broadcastlistBol = !1) : this.data.params.type && 3 == this.data.params.type ? (this.setData({
                active: 3
            }), this.data.apiType = "liveList", this.data.status = 2, this.getLiveList(2), this.data.announceListBol = !1) : this.data.params.type && 4 == this.data.params.type ? (this.setData({
                active: 4
            }), this.data.apiType = "playBack", this.getplayBack(), this.data.playBackDataBol = !1) : (this.setData({
                active: 1
            }), this.data.apiType = "recommend", this.getRecommend(), this.data.RecommendBol = !1), 
            this.getPlayBackShow();
        }
    }
});